package com.quaidi.smartlocker.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.quaidi.smartlocker.entity.OperationLog;
import com.quaidi.smartlocker.mapper.OperationLogMapper;
import com.quaidi.smartlocker.service.OperationLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * 操作日志Service实现类
 * 
 * @author QuaiDi
 * @since 2025-08-26
 */
@Service
public class OperationLogServiceImpl extends ServiceImpl<OperationLogMapper, OperationLog> implements OperationLogService {

    @Autowired
    private OperationLogMapper operationLogMapper;

    @Override
    public void recordLog(String operationType, String operator, Long targetId, String targetType, 
                         String operationDesc, String operationResult, String ipAddress) {
        OperationLog log = new OperationLog();
        log.setOperationType(operationType);
        log.setOperator(operator);
        log.setTargetId(targetId);
        log.setTargetType(targetType);
        log.setOperationDesc(operationDesc);
        log.setOperationResult(operationResult);
        log.setOperationTime(LocalDateTime.now());
        log.setIpAddress(ipAddress);
        operationLogMapper.insert(log);
    }
}